import { BasicColumn, FormSchema } from '@/components/Table';
import { VxeFormItemProps, VxeGridPropTypes } from '@/components/VxeTable';

import { Calendar, Tag } from 'ant-design-vue';
import { h } from 'vue';

type CheckedType = boolean | string | number;
export const columns: VxeGridPropTypes.Columns = [
  {
    type: 'checkbox',
    title: '',
    field: 'seq',
    align: 'center',
    width: 25,
  },
  {
    title: '物料编号',
    align: 'center',
    field: 'mtid0',
    children: [
      {
        field: 'mtid',
        showOverflow: 'title',
        align: 'center',
        width: 76,
        padding: false,
        filters: [{ data: '' }],
        filterMethod({ option, row, column }) {
          if (option.data) {
            return `${row[column.field]}`.indexOf(option.data) > -1;
          }
          return true;
        },
        slots: {
          header: 'header_mtid',
        },
      },
    ],
  },

  {
    title: '物料名称',
    align: 'center',
    field: 'mname0',
    children: [
      {
        field: 'mname',
        showOverflow: 'title',
        // width: 198,
        filters: [{ data: '' }],
        slots: {
          header: 'header_mname',
        },
      },
    ],
  },
  {
    title: '物料规格',
    align: 'center',
    field: 'guige0',
    children: [
      {
        field: 'guige',
        showOverflow: 'title',
        align: 'center',
        // width: 80,
        filters: [{ data: '' }],
        slots: {
          header: 'header_guige',
        },
      },
    ],
  },
  {
    title: '批次号',
    align: 'center',
    field: 'piCiHao0',
    children: [
      {
        title: '批次号',
        field: 'piCiHao',
        showOverflow: 'title',
        align: 'center',
        // width: 106,
        filters: [{ data: '' }],
        slots: {
          header: 'header_piCiHao',
        },
      },
    ],
  },
  {
    title: '型号',
    align: 'center',
    field: 'mmodel0',
    children: [
      {
        field: 'mmodel',
        showOverflow: 'title',
        align: 'center',
        filters: [{ data: '' }],
        slots: {
          header: 'header_mmodel',
        },
        width: 90,
      },
    ],
  },
  {
    title: '库存数量',
    field: 'quantity',
    showOverflow: 'title',
    align: 'center',
    width: 70,
    slots: {
      header: 'header_quantity_slot',
    },
    padding: true,
  },

  {
    title: '库位',
    field: 'kuWei',
    showOverflow: 'title',
    align: 'center',
    width: 160,
  },
  {
    title: '库容量',
    field: 'num',
    showOverflow: 'title',
    align: 'center',
    width: 60,
  },
  {
    title: '容量预警',
    field: 'residueNum',
    showOverflow: 'title',
    align: 'center',
    width: 70,
    slots: {
      default: 'residueNum_slot',
      // default: ({ row }) => {
      //   if (row.color) {
      //     return h(Tag, { color: row.color }, row.residueNum);
      //   } else {
      //     return row.residueNum;
      //   }
      // },
      header: 'header_residueNum_slot',
    },
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'keyword',
    label: '搜索',
    component: 'Input',
    componentProps: {
      placeholder: '请输入物料编号，物料名称,批号',
    },
    // colProps: { span: 5 },
  },
];
export const vxeTableFormSchema: VxeFormItemProps[] = [
  {
    span: 10,
    field: 'keyword',
    title: '搜索',
    itemRender: {
      props: {
        placeholder: '请输入物料编号，物料名称,批号',
      },
      name: 'AInput',
    },
  },
  {
    span: 4,
    itemRender: {
      name: 'VxeButtonGroup',
      options: [
        { type: 'reset', content: '重置' },
        { type: 'submit', content: '查询', status: 'primary' },
      ],
    },
  },
  {
    span: 10,
    title: '',
    slots: {
      default: 'form_item_slot',
    },
  },
];
